/*******************************************************************************
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.mylyn.rememberthemilk.ui.wizards;

import org.eclipse.jface.wizard.Wizard;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;

/**
 * @author Steffen Pingel
 */
public class NewRtmQueryWizard extends RepositoryQueryWizard {

	private static final String TITLE = "New RememberTheMilk Query";

//	private final TaskRepository repository;

	private RtmCustomQueryPage queryPage;

	private IRepositoryQuery query;

	public NewRtmQueryWizard(TaskRepository repository, IRepositoryQuery query) {
		super(repository);
//		this.repository = repository;
		this.query = query;

		setNeedsProgressMonitor(true);
		setWindowTitle(TITLE);
		// FIXME: this is internal now
		//setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
	}

	@Override
	public void addPages() {
		// FIXME: needs a proper name
		queryPage = new RtmCustomQueryPage(getTaskRepository(), "", query);
		queryPage.setWizard(this);
		addPage(queryPage);
	}

	@Override
	public boolean canFinish() {
		return queryPage.isPageComplete();
	}

	
//	@Override
//	public boolean performFinish() {
//		IRepositoryQuery query = queryPage.getQuery();
//		// FIXME reimplement
////		if (query != null) {
////			TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
////			AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
////					repository.getConnectorKind());
////			if (connector != null) {
////				TasksUiPlugin.getSynchronizationManager().synchronize(connector, query, null, true);
////			}
////		}
//		return true;
//	}

}